package tcnplanner;

import java.text.DateFormat;

/**
 *
 * @author Ruud
 */
public class vwInfo extends javax.swing.JPanel {

    private Reservation reservation;

    /** Creates new form vwInfo */
    public vwInfo() {
        initComponents();
    }
    
    public void setReservation(Reservation reservation){
        this.reservation = reservation;
        showInfo();
    }

    private void showInfo() {
        if (reservation != null) {
            Item handler = null;
            Item prober = null;
            Item tester = null;
            for (Item i : reservation.getTestSetup().getItems()) {
                switch (i.getType()) {
                    case HANDLER:
                        handler = i;
                        break;
                    case PROBER:
                        handler = i;
                        break;
                    case TESTER:
                        tester = i;
                        break;
                }
            }


            lbAantalProducten.setText(Integer.toString(reservation.getTest().getProductCount()));
            lbAdres.setText(reservation.getCustomer().getAdres());
            lbCommentaar.setText(reservation.getComment());
            //lbEindtijd.setText(reservation.getEndDate().toString());
            lbEmail.setText(reservation.getCustomer().getEmail());
            if (handler != null) {
                lbHandler.setText(handler.getName());
            }
            else {
                lbHandler.setText("N.B.");
            }
            lbNaam.setText(reservation.getCustomer().getName());
            if (prober != null) {
                lbProber.setText(prober.getName());
            }
            else {
                lbProber.setText("N.B.");
            }
            lbReserveringDate.setText(DateFormat.getTimeInstance(DateFormat.DEFAULT).format(reservation.getReservationDate()));
            lbReserveringStatus.setText(reservation.getStatus().name());
            if (reservation.getStatus() != Reservation.statusType.NEW) {
                lbStarttijd.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(reservation.getStartDate()));
            } else {
                lbStarttijd.setText("not planned yet");
            }
            
            this.lbEindtijd.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(reservation.getEndDate()));
            this.lbLokaal.setText(Integer.toString(reservation.getTestroom().getRoomNr()));
            //lbTestDate.setText(reservation.getStartDate().toString());
            lbTestID.setText(Integer.toString(reservation.getId()));
            //lbTestStatus.setText(reservation.getTest().getStatus().name());
            if(tester != null){
                lbTester.setText(tester.getName());
            }
            else {
                lbTester.setText("N.B.");
            }
            lbWaferFinal.setText(reservation.getTest().getTestType().name());
            lbAantalProducten.setText(Integer.toString(reservation.getTest().getProductCount()));
            //lbLokaal.setText(Integer.toString(reservation.getTestroom().getRoomNr()));
            lbTelNr.setText(reservation.getCustomer().getTelephone());
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lbProber = new javax.swing.JLabel();
        jProber = new javax.swing.JLabel();
        lbHandler = new javax.swing.JLabel();
        jHandler = new javax.swing.JLabel();
        lbAantalProducten = new javax.swing.JLabel();
        jWaferFinal = new javax.swing.JLabel();
        lbTester = new javax.swing.JLabel();
        jTester = new javax.swing.JLabel();
        lbTelNr = new javax.swing.JLabel();
        jTestID = new javax.swing.JLabel();
        lbEmail = new javax.swing.JLabel();
        lbNaam = new javax.swing.JLabel();
        jEindtijd = new javax.swing.JLabel();
        lbAdres = new javax.swing.JLabel();
        jCommentaar = new javax.swing.JLabel();
        jNaam = new javax.swing.JLabel();
        jAantalProducten = new javax.swing.JLabel();
        jStarttijd = new javax.swing.JLabel();
        jReserveringStatus = new javax.swing.JLabel();
        jReserveringDate = new javax.swing.JLabel();
        jKlant = new javax.swing.JLabel();
        jTestopstelling = new javax.swing.JLabel();
        jTest = new javax.swing.JLabel();
        lbWaferFinal = new javax.swing.JLabel();
        jReservering = new javax.swing.JLabel();
        lbReserveringStatus = new javax.swing.JLabel();
        lbStarttijd = new javax.swing.JLabel();
        lbEindtijd = new javax.swing.JLabel();
        lbCommentaar = new javax.swing.JLabel();
        jTel = new javax.swing.JLabel();
        jEmail = new javax.swing.JLabel();
        lbReserveringDate = new javax.swing.JLabel();
        lbTestID = new javax.swing.JLabel();
        jAdres = new javax.swing.JLabel();
        jRoom = new javax.swing.JLabel();
        lbLokaal = new javax.swing.JLabel();

        setBackground(java.awt.SystemColor.inactiveCaption);

        lbProber.setText("n.v.t.");
        lbProber.setName("lbProber"); // NOI18N

        jProber.setText("Prober:");
        jProber.setName("jProber"); // NOI18N

        lbHandler.setText("n.v.t.");
        lbHandler.setName("lbHandler"); // NOI18N

        jHandler.setText("Handler:");
        jHandler.setName("jHandler"); // NOI18N

        lbAantalProducten.setText("n.v.t.");
        lbAantalProducten.setName("lbAantalProducten"); // NOI18N

        jWaferFinal.setText("Wafer/Final:");
        jWaferFinal.setName("jWaferFinal"); // NOI18N

        lbTester.setText("n.v.t.");
        lbTester.setName("lbTester"); // NOI18N

        jTester.setText("Tester:");
        jTester.setName("jTester"); // NOI18N

        lbTelNr.setText("n.v.t.");
        lbTelNr.setName("lbTelNr"); // NOI18N

        jTestID.setText("ReservationID:");
        jTestID.setName("jTestID"); // NOI18N

        lbEmail.setText("n.v.t.");
        lbEmail.setName("lbEmail"); // NOI18N

        lbNaam.setText("n.v.t.");
        lbNaam.setName("lbNaam"); // NOI18N

        jEindtijd.setText("Eindtijd:");
        jEindtijd.setName("jEindtijd"); // NOI18N

        lbAdres.setText("n.v.t.");
        lbAdres.setName("lbAdres"); // NOI18N

        jCommentaar.setText("Commentaar:");
        jCommentaar.setName("jCommentaar"); // NOI18N

        jNaam.setText("Naam:");
        jNaam.setName("jNaam"); // NOI18N

        jAantalProducten.setText("Aantal producten:");
        jAantalProducten.setName("jAantalProducten"); // NOI18N

        jStarttijd.setText("Starttijd:");
        jStarttijd.setName("jStarttijd"); // NOI18N

        jReserveringStatus.setText("Status:");
        jReserveringStatus.setName("jReserveringStatus"); // NOI18N

        jReserveringDate.setText("Reservering date:");
        jReserveringDate.setName("jReserveringDate"); // NOI18N

        jKlant.setFont(new java.awt.Font("Tahoma", 1, 14));
        jKlant.setText("Klant:");
        jKlant.setName("jKlant"); // NOI18N

        jTestopstelling.setFont(new java.awt.Font("Tahoma", 1, 14));
        jTestopstelling.setText("Testopstelling:");
        jTestopstelling.setName("jTestopstelling"); // NOI18N

        jTest.setFont(new java.awt.Font("Tahoma", 1, 14));
        jTest.setText("Test:");
        jTest.setName("jTest"); // NOI18N

        lbWaferFinal.setText("n.v.t.");
        lbWaferFinal.setName("lbWaferFinal"); // NOI18N

        jReservering.setFont(new java.awt.Font("Tahoma", 1, 14));
        jReservering.setText("Reservering:");
        jReservering.setName("jReservering"); // NOI18N

        lbReserveringStatus.setText("n.v.t.");
        lbReserveringStatus.setName("lbReserveringStatus"); // NOI18N

        lbStarttijd.setText("n.v.t.");
        lbStarttijd.setName("lbStarttijd"); // NOI18N

        lbEindtijd.setText("n.v.t.");
        lbEindtijd.setName("lbEindtijd"); // NOI18N

        lbCommentaar.setText("n.v.t.");
        lbCommentaar.setName("lbCommentaar"); // NOI18N

        jTel.setText("Tel. nr.:");
        jTel.setName("jTel"); // NOI18N

        jEmail.setText("E-mail:");
        jEmail.setName("jEmail"); // NOI18N

        lbReserveringDate.setText("n.v.t.");
        lbReserveringDate.setName("lbReserveringDate"); // NOI18N

        lbTestID.setText("n.v.t.");
        lbTestID.setName("lbTestID"); // NOI18N

        jAdres.setText("Adres:");
        jAdres.setName("jAdres"); // NOI18N

        jRoom.setText("Lokaal:");
        jRoom.setName("jRoom"); // NOI18N

        lbLokaal.setText("n.v.t.");
        lbLokaal.setName("lbLokaal"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jReservering)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jProber)
                            .addComponent(jTester)
                            .addComponent(jHandler))
                        .addGap(65, 65, 65)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbHandler)
                            .addComponent(lbProber)
                            .addComponent(lbTester)
                            .addComponent(lbNaam)
                            .addComponent(lbAdres)
                            .addComponent(lbTelNr)
                            .addComponent(lbEmail)))
                    .addComponent(jTestopstelling)
                    .addComponent(jTest)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jAantalProducten)
                            .addComponent(jWaferFinal))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbAantalProducten)
                            .addComponent(lbWaferFinal)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTel)
                            .addComponent(jEmail)
                            .addComponent(jAdres)
                            .addComponent(jNaam)))
                    .addComponent(jKlant)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jReserveringDate)
                            .addComponent(jTestID)
                            .addComponent(jReserveringStatus)
                            .addComponent(jStarttijd)
                            .addComponent(jEindtijd)
                            .addComponent(jRoom)
                            .addComponent(jCommentaar))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbCommentaar)
                            .addComponent(lbReserveringStatus)
                            .addComponent(lbStarttijd)
                            .addComponent(lbEindtijd)
                            .addComponent(lbLokaal)
                            .addComponent(lbTestID)
                            .addComponent(lbReserveringDate))))
                .addContainerGap(60, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jReservering)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTestID)
                    .addComponent(lbTestID))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jReserveringDate)
                    .addComponent(lbReserveringDate))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jReserveringStatus)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jStarttijd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jEindtijd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRoom)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCommentaar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTest))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbReserveringStatus)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbStarttijd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbEindtijd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbLokaal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbCommentaar)))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jWaferFinal)
                        .addGap(6, 6, 6)
                        .addComponent(jAantalProducten))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbWaferFinal)
                        .addGap(6, 6, 6)
                        .addComponent(lbAantalProducten)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTestopstelling)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lbTester)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbProber)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbHandler))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTester)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jProber)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jHandler)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jKlant)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jTel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jEmail))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jNaam)
                            .addComponent(lbNaam))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jAdres)
                            .addComponent(lbAdres))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbTelNr)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbEmail)))
                .addContainerGap(38, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jAantalProducten;
    private javax.swing.JLabel jAdres;
    private javax.swing.JLabel jCommentaar;
    private javax.swing.JLabel jEindtijd;
    private javax.swing.JLabel jEmail;
    private javax.swing.JLabel jHandler;
    private javax.swing.JLabel jKlant;
    private javax.swing.JLabel jNaam;
    private javax.swing.JLabel jProber;
    private javax.swing.JLabel jReservering;
    private javax.swing.JLabel jReserveringDate;
    private javax.swing.JLabel jReserveringStatus;
    private javax.swing.JLabel jRoom;
    private javax.swing.JLabel jStarttijd;
    private javax.swing.JLabel jTel;
    private javax.swing.JLabel jTest;
    private javax.swing.JLabel jTestID;
    private javax.swing.JLabel jTester;
    private javax.swing.JLabel jTestopstelling;
    private javax.swing.JLabel jWaferFinal;
    private javax.swing.JLabel lbAantalProducten;
    private javax.swing.JLabel lbAdres;
    private javax.swing.JLabel lbCommentaar;
    private javax.swing.JLabel lbEindtijd;
    private javax.swing.JLabel lbEmail;
    private javax.swing.JLabel lbHandler;
    private javax.swing.JLabel lbLokaal;
    private javax.swing.JLabel lbNaam;
    private javax.swing.JLabel lbProber;
    private javax.swing.JLabel lbReserveringDate;
    private javax.swing.JLabel lbReserveringStatus;
    private javax.swing.JLabel lbStarttijd;
    private javax.swing.JLabel lbTelNr;
    private javax.swing.JLabel lbTestID;
    private javax.swing.JLabel lbTester;
    private javax.swing.JLabel lbWaferFinal;
    // End of variables declaration//GEN-END:variables
}